]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
environment: Monkey-patch iterate_children() generator
authorFlorian Müllner <fmuellner@gnome.org>
Tue, 19 May 2020 18:59:36 +0000 (20:59 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Tue, 19 May 2020 19:07:20 +0000 (21:07 +0200)
This is a small convenience method for using ClutterActor's iterator API
with javascript's built-in iterator protocol, for example as:

  for (let child of container.iterate_children())
      doStuff(child);

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1268

js/ui/environment.js

index 4a123140248d8bc78174680a76b90a6a731bdc79..44a92db3613e2550612bd019672fff6891ce2751 100644 (file)
@@ -285,6 +285,11 @@ function init() {
         _easeActorProperty(this, 'value', target, params);
     };
 
+    Clutter.Actor.prototype.iterate_children = function* () {
+        for (let c = this.get_first_child(); c; c = c.get_next_sibling())
+            yield c;
+    };
+
     Clutter.Actor.prototype.toString = function () {
         return St.describe_actor(this);
     };